﻿<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="Expires" content="0" />
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="/favicon.ico" >
	<link rel="stylesheet" href="/layui.css"  media="all">
<link rel="Shortcut Icon" href="/favicon.ico" />



<title>新建网站角色 - 管理员管理 - H-ui.admin v3.1</title>
<meta name="keywords" content="H-ui.admin v3.1,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
<meta name="description" content="H-ui.admin v3.1，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
	<meta charset="utf-8">
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="/layui.css"  media="all">

</head>
<body>
<form class="layui-form layui-form-pane" action="/addMesSource">
   <input type="hidden" id="typeId" name="typeId">
	<input type="hidden" id="classifiedPacketId" name="cpid">

   <div class="layui-form-item">
	   <label class="layui-form-label">渠道类型</label>
	   <div   class="layui-input-block">
		   <select lay-filter="type"  >
			   <option value="">请选择渠道类型</option>
			   <option th:each="typeDict :${typeDicts}" th:value="${typeDict.tid}"  th:text="${typeDict.tname}"  ></option>
		   </select>
	   </div>
   </div>

	<div class="layui-form-item">
		<label class="layui-form-label">所属分类</label>
		<div class="layui-input-block">
			<select name="" lay-filter="classifiedPacketId">
				<option value="">请选择所属分类</option>
				<option th:each="classifiedPacket:${classifiedPackets}" th:value="${classifiedPacket.pid}" th:text="${classifiedPacket.pname}" ></option>

			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">渠道名称</label>
		<div class="layui-input-block">
			<input type="text" id="sname" name="sname" required  lay-verify="required" autocomplete="off"  class="layui-input">
		</div>
	</div>
	<div class="layui-form-item">
		<div id="button_relative" class="layui-input-block">
			<button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
			<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
	</div>
</form>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="/layui.all.js"></script>
<script  th:inline="javascript" type="text/javascript">




  layui.use('form', function(){
      var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功

      //……

      //但是，如果你的HTML是动态生成的，自动渲染就会失效
      //因此你需要在相应的地方，执行下述方法来手动渲染，跟这类似的还有 element.init();
      form.render();
      form.on('select(type)', function(data){

          $("#typeId").attr("value",data.value);
          console.log(data.elem); //得到select原始DOM对象
          console.log(data.value); //得到被选中的值
          console.log(data.othis); //得到美化后的DOM对象
      });
      form.on('select(classifiedPacketId)', function(data){

          $("#classifiedPacketId").attr("value",data.value);
          console.log(data.elem); //得到select原始DOM对象
          console.log(data.value); //得到被选中的值
          console.log(data.othis); //得到美化后的DOM对象
      });

      form.on('submit(formDemo)', function(data){
		  var flag=true;
          if(    $("#typeId").val()=="" ){
              layer.msg('请选择渠道类型');
              return false;
          }
          if($("#classifiedPacketId").val()=="" ){
              layer.msg('请选择所属分类');
              return false;
          }

          //判断是否有同名渠道
          $.post("/queryMesSourceByName",
              {
                  sname:$("#sname").val(),
              },
              function (data,index, item) {
                var datares=eval(data);
                       if(true){
                           alert("11111")
                           flag=false;
					   }

              },"json")
          return flag;
      });

  });


</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>